package com.java.huxb.day06.thread;

/**
 * @author huxb
 * @date 2020/4/4 0004 下午 8:27
 */
public class TicketThread implements  Runnable {

    private  Integer count;

    public TicketThread(Integer count) {
        this.count = count;
    }
    static String obj = "a";
    @Override
    public void run() {
        while (count > 0) {
            synchronized (TicketThread.class) {
                try {
                    Thread.sleep(300);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                if (count > 0) {
                    System.out.println(Thread.currentThread().getName() + "正在售卖第" + count-- +"张票");
                } else {
                    System.out.println("票买完了！");
                }
            }
        }
    }
}
